﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

using Htss.Platform.Data;

namespace DreamBox.DAL.Picture
{
    public class Picture
    {
        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="PicID"></param>
        /// <returns></returns>
        public bool Delete(int PicID)
        {
            DbAction action = new DbAction("dbox_Picture");
            action.SetFields("PicID", PicID, DbFieldType.Condition);
            return action.Delete();
        }
        /// <summary>
        /// 更新图片加次数
        /// </summary>
        /// <param name="PicID"></param>
        /// <returns></returns>
        public bool Update(int PicID)
        {
            DbAction action = new DbAction();
            action.SetFields("PicID", PicID, DbFieldType.Condition);
            return action.ExecuteSqlNonQuery("update dbox_Picture set Plus=Plus+1 where PicID=@PicID");
        }
        /// <summary>
        /// 更新图片信息
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool Update(DreamBox.Model.Picture m)
        {
            DbAction action = new DbAction("dbox_Picture");
            action.SetFields("PicID", m.PicID, DbFieldType.Condition);
            action.SetFields("Title", m.Title);
            action.SetFields("Description", m.Description);
            return action.Update();
        }
        /// <summary>
        /// 添加图片
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool Add(DreamBox.Model.Picture m)
        {
            DbAction action = new DbAction("dbox_Picture");
            action.SetFields("ImgUrl",m.ImgUrl);
            action.SetFields("Title", m.Title);
            action.SetFields("Description",m.Description);
            action.SetFields("UploadDate",DateTime.Now);
            //action.SetFields("AlbumsID",m.AlbumsID);
            action.SetFields("UserID", m.UserID);
            action.SetFields("Plus", 0);
            return action.Insert();
        }
    }
}
